package com.hxl.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

//1.制作通知类，在类中定义一个方法用于完成共性功能
public class AOPAdvice {

    public void before(JoinPoint jp,int x,int y)
    {
        Object[] args = jp.getArgs();
        System.out.println("在原始方法运行前运行..."+args[0]+args[1]);
        System.out.println(x+","+y);
        //int i = 1/0;
    }

    public void after()
    {
        System.out.println("在原始方法运行后运行");
    }

    public void afterReturning(Object ret)
    {
        System.out.println("方法正常运行后执行");
        System.out.println(ret);
    }
    public void afterThrowing(Throwable t)
    {
        System.out.println("原始方法抛异常后执行..."+t.getMessage());
    }

    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        Object res = pjp.proceed();
        System.out.println(res);
        return res;
    }
}
